//===========================[ 8 / 18 / 2011 LVI ]=============================
//				Copyright c Vitaly Lyaschenko <SkyChameleon@gmail.com>
//								Source file
// Purpose: 
//=============================================================================
#include "cRootObject.h"
#include "Kernel.h"

RootObject::RootObject() :
	m_pParent(NULL),
	m_pRender(NULL),
	m_pScript(NULL),
	//m_pEffect(NULL),
	is_Child(false)
{
	m_ChildrenList.clear();

	_mtl::identity(mtrModel);
	_mtl::identity(localTransform);


}

RootObject::~RootObject()
{
	m_pParent = NULL;
}

void RootObject::setParent( RootObject * pParent )
{
	m_pParent = pParent;
}

void RootObject::pushChild( RootObject * pChild )
{
	ASSERT( pChild );
	pChild->setParent( this );
	m_ChildrenList.push_back(pChild);
	is_Child = true;
}

void RootObject::popChild()
{
	m_ChildrenList.pop_back();
}

void RootObject::clearChildrenList()
{
	auto itBeg = m_ChildrenList.begin();
	auto itEnd = m_ChildrenList.end();

	std::for_each(itBeg,itEnd,delete_pointed_to<RootObject>);
}


std::vector<RootObject*>* RootObject::getChildrenList()
{
	return &m_ChildrenList;
}